# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgbase=dav1d
pkgname=(dav1d dav1d-doc)
pkgver=1.3.0
pkgrel=1
pkgdesc='AV1 cross-platform decoder focused on speed and correctness'
url='https://code.videolan.org/videolan/dav1d/'
arch=('loong64' 'x86_64')
license=('BSD')
makedepends=('meson' 'ninja' 'nasm' 'doxygen' 'graphviz' 'xxhash')
source=(https://downloads.videolan.org/pub/videolan/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
        https://code.videolan.org/videolan/dav1d-test-data/-/archive/${pkgver}/dav1d-test-data-${pkgver}.tar.gz)
sha512sums=('a91d217b8656c452dd80f5597e988f0e7a2ea32b12092c2695e7dc388033db7b193f7a8c98413bec31d1c38af376561d39f7618b935c4feeb6498c5d2b43f6a4'
            'SKIP'
            'ec066c690bb1db307cf2a002ddc0a1f0fa77fa8dafbb07fe74da3fbaf6d43b536e673c309f7665d197ef0ad606968040acdcb8252fdf286e749f6ac2de94ac24')
b2sums=('aa79eaa22adde287a31ed60b88ae8d4095e18b92359a7e30aecd13c10eafe07acdeeb2f0bdb232acc6b136cdbd87626ac641df0615683d50f355edfd6c028caf'
        'SKIP'
        '748edf8edbca716ea6742ef6d79b34bf6947b5cbdde213c4cefce43e6b5d9954ca302b880f07d70337b1a6e9a31fba98f588616c8f9a8dd4187518f08bf285e8')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${pkgbase}-${pkgver}
  ln -s "${srcdir}/dav1d-test-data-${pkgver}" tests/dav1d-test-data
}

build() {
  cd ${pkgbase}-${pkgver}
  arch-meson \
    -Dtestdata_tests=true \
    -Denable_docs=true \
    build
  ninja -C build all doc/html
}

check() {
  cd ${pkgbase}-${pkgver}/build
  meson test
}

package_dav1d() {
  depends=('glibc')
  provides=('libdav1d.so')
  optdepends=('dav1d-doc: HTML documentation')

  cd ${pkgbase}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 README.md CONTRIBUTING.md NEWS -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

package_dav1d-doc() {
  pkgdesc+=" (documentation)"

  cd ${pkgbase}-${pkgver}
  install -d "${pkgdir}/usr/share/doc/${pkgbase}"
  cp -r build/doc/html -t "${pkgdir}/usr/share/doc/${pkgbase}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
